package com.ty.tour.common.utils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ReturnData<T> implements Serializable {
	private  int status;
    private String massage;
    private long Total;
    private T data ;

    public ReturnData() {
    }

    public ReturnData(int status, String massage, long total, T data) {
        this.status = status;
        this.massage = massage;
        Total = total;
        this.data = data;
    }
    public ReturnData statusTool(Integer i){
        List<Integer> list=new ArrayList<>();
        list.add(i);
        if (i>0){
            return success(list,list.size());
        }else{
            return fail();
        }
    }

    public static <T> ReturnData success(T data, long total) {
        ReturnData returnData = new ReturnData();
        returnData.setStatus(0);
        returnData.setMassage("处理成功..");
        returnData.setData(data);
        returnData.setTotal(total);
        System.out.println(returnData.toString());
        return returnData;
    }
    public ReturnData fail() {
        ReturnData returnData = new ReturnData();
        returnData.setStatus(1);
        returnData.setMassage("处理失败..");
        System.out.println(returnData.toString());
        return returnData;
    }

    public static  ReturnData fail(String msg){
        ReturnData returnData = new ReturnData();
        returnData.setStatus(1);
        returnData.setMassage(msg);
        System.out.println(returnData.toString());
        returnData.setTotal(0);
        return returnData;
    }
//    public ReturnData add(Object value) {
//        this.data.add(value);
//        return this;
//    }
    public int getStatus() {
        return status;
    }
    public String getMassage() {
        return massage;
    }
    public T getData() {
        return data;
    }
    public void setStatus(int status) {
        this.status = status;
    }
    public void setMassage(String massage) {
        this.massage = massage;
    }
    public void setData(T data) {
        this.data = data;
    }

    public long getTotal() {
        return Total;
    }

    public void setTotal(long total) {
        Total = total;
    }

    @Override
    public String toString() {
        return "ReturnData{" +
                "status=" + status +
                ", massage='" + massage + '\'' +
                ", Total=" + Total +
                ", data=" + data +
                "}";
    }
	public void setData(Map<String, String> dataMap) {
		// TODO Auto-generated method stub
		
	}
}
